// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl;

public sealed partial class TermsLookup
{
	[JsonInclude, JsonPropertyName("id")]
	public Elastic.Clients.Elasticsearch.Serverless.Id Id { get; set; }
	[JsonInclude, JsonPropertyName("index")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexName Index { get; set; }
	[JsonInclude, JsonPropertyName("path")]
	public Elastic.Clients.Elasticsearch.Serverless.Field Path { get; set; }
	[JsonInclude, JsonPropertyName("routing")]
	public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; }
}

public sealed partial class TermsLookupDescriptor<TDocument> : SerializableDescriptor<TermsLookupDescriptor<TDocument>>
{
	internal TermsLookupDescriptor(Action<TermsLookupDescriptor<TDocument>> configure) => configure.Invoke(this);

	public TermsLookupDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.Id IdValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexName IndexValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Field PathValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Routing? RoutingValue { get; set; }

	public TermsLookupDescriptor<TDocument> Id(Elastic.Clients.Elasticsearch.Serverless.Id id)
	{
		IdValue = id;
		return Self;
	}

	public TermsLookupDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.Serverless.IndexName index)
	{
		IndexValue = index;
		return Self;
	}

	public TermsLookupDescriptor<TDocument> Path(Elastic.Clients.Elasticsearch.Serverless.Field path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor<TDocument> Path<TValue>(Expression<Func<TDocument, TValue>> path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor<TDocument> Path(Expression<Func<TDocument, object>> path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor<TDocument> Routing(Elastic.Clients.Elasticsearch.Serverless.Routing? routing)
	{
		RoutingValue = routing;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("id");
		JsonSerializer.Serialize(writer, IdValue, options);
		writer.WritePropertyName("index");
		JsonSerializer.Serialize(writer, IndexValue, options);
		writer.WritePropertyName("path");
		JsonSerializer.Serialize(writer, PathValue, options);
		if (RoutingValue is not null)
		{
			writer.WritePropertyName("routing");
			JsonSerializer.Serialize(writer, RoutingValue, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class TermsLookupDescriptor : SerializableDescriptor<TermsLookupDescriptor>
{
	internal TermsLookupDescriptor(Action<TermsLookupDescriptor> configure) => configure.Invoke(this);

	public TermsLookupDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.Id IdValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexName IndexValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Field PathValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Routing? RoutingValue { get; set; }

	public TermsLookupDescriptor Id(Elastic.Clients.Elasticsearch.Serverless.Id id)
	{
		IdValue = id;
		return Self;
	}

	public TermsLookupDescriptor Index(Elastic.Clients.Elasticsearch.Serverless.IndexName index)
	{
		IndexValue = index;
		return Self;
	}

	public TermsLookupDescriptor Path(Elastic.Clients.Elasticsearch.Serverless.Field path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor Path<TDocument, TValue>(Expression<Func<TDocument, TValue>> path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor Path<TDocument>(Expression<Func<TDocument, object>> path)
	{
		PathValue = path;
		return Self;
	}

	public TermsLookupDescriptor Routing(Elastic.Clients.Elasticsearch.Serverless.Routing? routing)
	{
		RoutingValue = routing;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("id");
		JsonSerializer.Serialize(writer, IdValue, options);
		writer.WritePropertyName("index");
		JsonSerializer.Serialize(writer, IndexValue, options);
		writer.WritePropertyName("path");
		JsonSerializer.Serialize(writer, PathValue, options);
		if (RoutingValue is not null)
		{
			writer.WritePropertyName("routing");
			JsonSerializer.Serialize(writer, RoutingValue, options);
		}

		writer.WriteEndObject();
	}
}